filechooser: Fallback if content-type unavailable
authorBastien Nocera <hadess@hadess.net>
Fri, 28 Feb 2020 15:59:19 +0000 (16:59 +0100)
committerBastien Nocera <hadess@hadess.net>
Fri, 28 Feb 2020 16:33:08 +0000 (17:33 +0100)
Fallback to fast-content-type if the content-type attribute isn't
available, as is the case for most remote filesystems.

Closes: #2482
gtk/gtkfilechooserwidget.c
gtk/gtkfilesystemmodel.c

index adee2ab5d8211e82d7198d5a1d227e200e2f93f7..4b5db9e972dae13c7c629deddce092db553f8ff1 100644 (file)
@@ -393,7 +393,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 #define MODEL_ATTRIBUTES "standard::name,standard::type,standard::display-name," \
                          "standard::is-hidden,standard::is-backup,standard::size," \
-                         "standard::content-type,time::modified,time::access," \
+                         "standard::content-type,standard::fast-content-type,time::modified,time::access," \
                          "access::can-rename,access::can-delete,access::can-trash," \
                          "standard::target-uri"
 enum {
@@ -4599,6 +4599,8 @@ get_type_information (GtkFileChooserWidget *impl,
 
   GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
   content_type = g_file_info_get_content_type (info);
+  if (!content_type)
+    content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
   if (!content_type)
     goto end;
 
index e7c4bd8bbb2aca655f55775b0e54d9b209969749..eeab450301647d03b4a8389dffbba95b65a9a473 100644 (file)
@@ -397,6 +397,10 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
   if (required & GTK_FILE_FILTER_MIME_TYPE)
     {
       const char *s = g_file_info_get_content_type (node->info);
+
+      if (!s)
+        s = g_file_info_get_attribute_string (node->info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+
       if (s)
        {
          mime_type = g_content_type_get_mime_type (s);